<template>
  <div>
    <div class="dog">
      <h2>狗名称：{{ name }}</h2>
      <h2>狗年龄：{{ age }}</h2>
      <button @click="sendDogName">把狗的名称给App</button>
    </div>
  </div>
</template>

<script>
export default {
  name: "Dog",
  data() {
    return {
      name: "张三",
      age: 18,
    }
  },
  methods: {
    sendDogName() {
      this.$emit("showDogName", this.name)
    }
  }
}
</script>

<style scoped>
.dog {
  background-color: green;
}
</style>